import request from '@/config/axios'

// 形式发票 VO
export interface CommercialInvoiceVO {
  id: number //  编号
  no: string // 编号
  invoiceDate: Date // 订单时间
  dueDate: Date // 到期时间
  kind: string // 订单类型
  customerId: number // 客户
  brandId: number // 品牌
  supplierId: number // 供应商
  buyer: string // 购买人
  supplerManager: string // 供应商联系人
  shipTo: string // 发货地址
  po: string // P.O.#
  notes: string // 注释
  payAction: string // 付款方式
  term: string // 期满
  bill: string // 账单
  remarks: string // 备注
  count: number // 数量
  productSaleUs: number // 商品价格$
  productSaleRmb: number // 商品价格¥
  productPurhaseUs: number // 采购价格$
  productPurhaseRmb: number // 采购价格¥
  otherSaleUs: number // 其他销售费用$
  otherSaleRmb: number // 其他销售费用¥
  otherPurhaseUs: number // 其他采购费用$
  otherPurhaseRmb: number // 其他采购费用¥
  discountSaleUs: number // 销售折扣$
  discountSaleRmb: number // 销售折扣¥
  discountPurhaseUs: number // 采购折扣$
  discountPurhaseRmb: number // 采购折扣¥
  totalSaleUs: number // 销售总价$
  totalSaleRmb: number // 销售总价¥
  totalPurhaseUs: number // 采购总价$
  totalPurhaseRmb: number // 采购总价¥
}

// 形式发票 API
export const CommercialInvoiceApi = {
  // 查询形式发票分页
  getCommercialInvoicePage: async (params: any) => {
    return await request.get({ url: `/su/commercial-invoice/page`, params })
  },

  // 查询形式发票详情
  getCommercialInvoice: async (id: number) => {
    return await request.get({ url: `/su/commercial-invoice/get?id=` + id })
  },

  refreshPdf: async (id: number) => {
    return await request.get({ url: `/su/commercial-invoice/pdf?id=` + id })
  },

  // 新增形式发票
  createCommercialInvoice: async (data: CommercialInvoiceVO) => {
    return await request.post({ url: `/su/commercial-invoice/create`, data })
  },

  // 修改形式发票
  updateCommercialInvoice: async (data: CommercialInvoiceVO) => {
    return await request.put({ url: `/su/commercial-invoice/update`, data })
  },

  updateCommercialInvoiceStatus: async (data: CommercialInvoiceVO) => {
    return await request.put({ url: `/su/commercial-invoice/updateStatus`, data })
  },

  // 删除形式发票
  deleteCommercialInvoice: async (id: number) => {
    return await request.delete({ url: `/su/commercial-invoice/delete?id=` + id })
  },

  confirmCommercialInvoice: async (id: number) => {
    return await request.put({ url: `/su/commercial-invoice/confirm?id=` + id })
  },

  // 导出形式发票 Excel
  exportCommercialInvoice: async (params) => {
    return await request.download({ url: `/su/commercial-invoice/export-excel`, params })
  }
}
